package com.tpay.server.util;

import com.google.inject.AbstractModule;
import com.google.inject.Inject;
import com.google.inject.Singleton;
import com.google.inject.persist.PersistService;
import com.google.inject.persist.jpa.JpaPersistModule;
import com.tpay.server.GeneralDao;
import com.tpay.server.GeneralDaoImpl;

public class MyGuiceModule extends AbstractModule {

	@Override
	protected void configure() {
		this.install(new JpaPersistModule("TEST-PU"));
		this.bind(JpaInitializer.class).asEagerSingleton();
		this.bind(GeneralDao.class).to(GeneralDaoImpl.class);
	}
}

@Singleton
class JpaInitializer {
	@Inject
	JpaInitializer(PersistService service) {
		service.start();
	}
}
